package lesson11;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;

public class Demo_1103 {
    public static void main(String[] args) {
        System.out.println(" 线程安全的list");
        List<Integer> list=new CopyOnWriteArrayList<>(new ArrayList<>());

        for (int i = 0; i < 10; i++) {
            Thread thread = new Thread(() -> {
                list.add(1);
                System.out.println(list);
            });
            thread.start();
        }

    }
}
